package com.xcity.pomelo.response;

import com.xcity.game.combat.attr.CombatAttributeFormatter;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.attr.response.CombatAttributeInfo;
import com.xcity.game.skill.template.SkillLevelUpTemplate;
import com.xcity.game.skill.v2.DefaultSkillV2;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class SkillLevelUpV2Response extends Response {
	
	public long id; // 对象id（玩家/员工）
	public int skillId; // 技能id
	public int level; // 技能等级
	public Object[] params; // 技能升级后的参数（用于构造技能描述）
	public Required next; // 下一级需求
	public CombatAttributeInfo enhanced; // 加强的属性
	
	public static class Required {
		public int gold = -1;
		public int points = -1;
		Required(DefaultSkillV2 skill) {
			SkillLevelUpTemplate slut = skill.getTemplate().getUpLvlTemplate(skill.getLevel() + 1);
			if (slut != null) {
				gold = slut.getGold();
				points = slut.getPoints();
			}
		}
	}
	
	public SkillLevelUpV2Response(int serial, long ownerId, DefaultSkillV2 skill) {
		super(serial);
		this.id = ownerId;
		this.skillId = skill.getId();
		this.level = skill.getLevel();
		this.params = skill.getParams();
		this.next = new Required(skill);
		CombatAttributeType[] enhanceTypes = skill.getEffector().getEnhanceTypes();
		if (enhanceTypes != null && enhanceTypes.length > 0) {
			CombatAttributeType type = enhanceTypes[0];
//			CombatableBase owner = (CombatableBase) skill.getVm().getOwner();
			float _val = skill.getTemplate().getGrowthVal(0); // 成长百分比值
			Object val = CombatAttributeFormatter.Formatters.PERCENT.format(_val / 100f);
			this.enhanced = new CombatAttributeInfo(type, val);
		}
	}
	

}
